﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SystemParamManager.aspx.cs"
    Inherits="ZLDC.Estate.TM.SystemParamManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>基本数据查询</title>
    <base target="_self" />
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../js/jquery/style/jquery.hiAlerts.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="divSearch" style="margin-top: 5px; text-align: center;">
        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
            <tr>
                <td style="width: 30%; text-align: left; background-color: #FFFFFF; cursor: pointer;"
                    valign="middle">
                    &nbsp;<span>常量类型:</span>&nbsp;
                    <select id="sType" name="sType" style="width: 100px;" runat="server" onchange="return search()">
                    </select>
                </td>
                <td style="text-align: left; background-color: #FFFFFF; cursor: pointer;" valign="middle">
                </td>
            </tr>
        </table>
    </div>
    <div id="divHead" style="margin-top: 2px; margin-bottom: 2px;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td height="24" bgcolor="#353c44">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>
                                <img src="../images/tb.gif" width="14" height="14" /><span class="STYLE1">基本数据列表</span>
                            </td>
                            <td>
                                <div align="right" id="divOperator">
                                    <span class="STYLE1">
                                        <img src="../images/add.gif" width="10" height="10" />
                                        <a a href='javascript:detail(0)' style="color: White;">基本数据新增</a> &nbsp;&nbsp;
                                    </span>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <div id="divList">
    </div>
    <div id="divPage">
    </div>

    <script src="../js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../js/jquery/jquery.hiAlerts-min.js" type="text/javascript"></script>

    <script src="../js/LexunJS.js" type="text/javascript"></script>

    <script src="../js/jShowDiv.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">
        var currentPage = 1; // 当前页
        var pageSize = 20; // 每页显示多少条
        var pageall = 0; // 总页数
        var total = 0; // 总记录数

        // 读取列表
        $(function() {
            showList(currentPage);
        });

        // 条件查询资源列表

        function showList(currentPage) {
            var type = LexunJS.GetSelectText("sType");

            $("#divList").html("<img src=\"../images/loading.gif\" />"); // 清空列表 
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerSystem.ashx',
                data: 'act=systemparam_list&page=' + currentPage + '&pagesize=' + pageSize + '&type=' + type,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙,请稍候后试！");
                }, success: function(json) {
                    listCallBack(json);
                }
            });
        }

        /*
        功能: 将返回的json数据进行排版
        json: json数据
        */

        function listCallBack(response) {
            var json = eval("(" + response + ")");
            var record = json.record;

            if (record == null || record.length == 0) {
                $("#divList").html("<font color='red'>&nbsp;系统内暂无您查询的信息!</font>");
                return;
            }

            var page = json.page;

            currentPage = page.currentpage;
            pageall = parseInt(page.pageall);
            total = page.total;

            var arr = [];
            arr.push("<table id='table1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
            arr.push("<tr>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("序号");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("常量类型");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("常量数据");
            arr.push("</td>");
            arr.push("<td height='25' bgcolor='d3eaef' class='STYLE6'>");
            arr.push("基本操作");
            arr.push("</td>");
            arr.push("</tr>");

            var recordLength = record.length;
            for (var i = 0; i < recordLength; i++) {
                if (i % 2 == 0)
                    arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#FFFFFF' style='cursor: pointer;' >");
                else
                    arr.push("<tr id='tr_" + record[i].id + "' bgcolor='#EEEDED' style='cursor: pointer;' >");

                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].id);
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].type);
                arr.push("</td>");
                arr.push("<td height='20' class='STYLE6'>");
                arr.push(record[i].item);
                arr.push("</td>");
                arr.push("<td height='20'  class='STYLE6'>");
                arr.push("<a href='javascript:detail(" + record[i].id + ")'>修改</a> | ");
                arr.push("<a href='javascript:del(" + record[i].id + ")'>删除</a>");
                arr.push("</td>");
                arr.push("</tr>");
            }
            arr.push("</table>");
            $("#divList").html(arr.join('')); // 显示列表

            $("#divPage").html(""); // 清空
            if (pageall > 1) {
                var pageHtml = LexunJS.showPage(currentPage, pageall, "showList"); // 分页
                $("#divPage").html(pageHtml);
            }
        }

        // 条件查询
        function search() {
            $("#divList").html(""); // 清空列表        
            $("#divPage").html(""); // 清空分页
            showList(1);
        }

        // 详细信息
        function detail(id) {
//            var width = 400;
//            var height = 200;
//            var iframe = "<iframe id=\"iframe_" + id + "\"  width=\"" + width + "\" height=\"" + (height - 30) + "\" frameborder=\"0\" scrolling=\"no\" src=\"SystemParamAdd.aspx?id=" + id + "\" />";
//            var title = "修改常量";
//            var divId = "divList";

//            dialog(iframe, title, width, height, divId);

            var path = "SystemParamAdd.aspx?id=" + id;
            var parameter = "";
            var style = "dialogWidth:400px; dialogHeight:200px; status:0;scroll:1; help:0; resizable:1;Scrollbars=yes,Toolbar=no,Location=no,Direction=no,Resizeable=no";
            window.showModalDialog(path, parameter, style);
            showList(1);
        }

        // 删除
        function del(id) {
            hiConfirm("您确定要删除该行，请谨慎操作！", "确认框", function(result) {
                if (result) {
                    // ajax删除                   
                    $.ajax({
                        type: 'POST',
                        url: '../Handler/HandlerSystem.ashx',
                        data: 'act=systemparam_del&id=' + id,
                        timeout: '10000',
                        error: function() {
                            alert("删除失败！");
                        }, success: function(outmsg) {
                            showList(currentPage);
                        }
                    });
                }
            });
        }
            
            
    </script>

</body>
</html>
